package com.mt.roll.wms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mt.roll.core.api.Assert;
import com.mt.roll.core.base.BaseService;
import com.mt.roll.core.dal.entity.CarTaskExecutionInfo;
import com.mt.roll.core.dal.entity.StorageBox;
import com.mt.roll.core.dal.service.StorageBoxServiceBiz;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.mapper.StorageBoxVoMapper;
import com.mt.roll.wms.params.StorageBoxQueryParam;
import com.mt.roll.wms.service.StorageBoxService;
import com.mt.roll.wms.vo.CarTaskExecutionInfoVo;
import com.mt.roll.wms.vo.StorageBoxCircInfoVo;
import com.mt.roll.wms.vo.StorageBoxVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @auther why
 * @date 2021/10/8 10:25
 */
@Service
@Transactional
public class StorageBoxServiceImpl extends BaseService implements StorageBoxService {

    @Autowired
    private StorageBoxVoMapper storageBoxVoMapper;

    @Autowired
    private StorageBoxServiceBiz storageBoxServiceBiz;

    @Override
    public R<PageVo<StorageBoxVo>> pageForBind(StorageBoxQueryParam storageBoxQueryParam) {
        IPage<StorageBoxVo> storageBoxVoIPage = new Page<>(storageBoxQueryParam.getCurrent(),storageBoxQueryParam.getSize());
        IPage<StorageBoxCircInfoVo> page = storageBoxVoMapper.pageForBind(storageBoxVoIPage, storageBoxQueryParam);
        return successful(new PageVo<>(page,StorageBoxVo.class));
    }

    @Override
    public R<StorageBoxVo> get(IdParam idParam) {
        StorageBox storageBox = storageBoxServiceBiz.getById(idParam.getId());
        Assert.notNull("存储箱上架详情不存在", storageBox);
        StorageBoxVo storageBoxVo = storageBoxVoMapper.getById(idParam.getId());
        return successful(storageBoxVo);
    }
}
